home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Software Contest 3
/
FM Towns Software Contest 3.iso
/
exp
/
astral
/
a1
/
game
/
source
/
test.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-07
|
4KB
|
198 lines
// "test.c"
// サンプルプログラム
#define MAIN
#include <stdio.h>
#include <egb.h>
#include <snd.h>
#include <spr.h>
#include "wire3d.h"
#include "sin8.c"
#define NON_INT
// マクロ設定
#define JOY_UP(A) if((A&0x01)==0)
#define JOY_DOWN(A) if((A&0x02)==0)
#define JOY_LEFT(A) if((A&0x04)==0)
#define JOY_RIGHT(A) if((A&0x08)==0)
#define JOY_TRIG_A(A) if((A&0x10)==0)
#define JOY_TRIG_B(A) if((A&0x20)==0)
#define JOY_SELECT(A) if((A&0x03)==0)
#define JOY_RUN(A) if((A&0x0c)==0)
// グローバル変数設定
char Gwork[1536];
SCREEN_LOCATE Screen[MAX_OBJECT];
int W_page=0,D_page=1,Draw_end=2,End_code=0,W;
ANGLE Angle[3]={0,0,0},Angle_w[3]={0,0,0};
int Offset[3]={0,0,0},Offset1[3]={0,0,0};
int Step;
#define OBJ_NUM 1
WIRE_SPACE Space[OBJ_NUM]={
{ 0,{ 0, 0, 0},{ 0, 0, 1000}},
};
int H_i;
int H_offset2[3];
// 関数
void VSYNC_handler(void)
{
if(Draw_end==1){
W=D_page;D_page=W_page;W_page=W;
chgpage(D_page);
Draw_end=2;
}
/*
Angle[1]-=Step;
return;
*/
H_i=pad_in();
JOY_RUN(H_i){
End_code=1;
}
JOY_SELECT(H_i){
End_code=1;
}
JOY_UP(H_i){
Angle_w[0]-=Step;
}
JOY_DOWN(H_i){
Angle_w[0]+=Step;
}
JOY_LEFT(H_i){
Angle_w[1]+=Step;
}
JOY_RIGHT(H_i){
Angle_w[1]-=Step;
}
JOY_TRIG_A(H_i){
H_offset2[1]=( (Step*20)*sin_data[Angle[0]]);
H_offset2[2]=( (Step*20)*cos_data[Angle[0]])>>7;
H_offset2[0]=(-H_offset2[2] * sin_data[Angle[1]]);
H_offset2[2]=( H_offset2[2] * cos_data[Angle[1]]);
Offset1[0]+=H_offset2[0];
Offset1[1]+=H_offset2[1];
Offset1[2]+=H_offset2[2];
}
JOY_TRIG_B(H_i){
H_offset2[1]=( (Step*40)*sin_data[Angle[0]]);
H_offset2[2]=( (Step*40)*cos_data[Angle[0]])>>7;
H_offset2[0]=(-H_offset2[2] * sin_data[Angle[1]]);
H_offset2[2]=( H_offset2[2] * cos_data[Angle[1]]);
Offset1[0]-=H_offset2[0];
Offset1[1]-=H_offset2[1];
Offset1[2]-=H_offset2[2];
}
#ifndef NON_INT
if(Draw_end==2){
#endif
Angle[0]=Angle_w[0];
Angle[1]=Angle_w[1];
Angle[2]=Angle_w[2];
Offset[0]=Offset1[0]>>7;
Offset[1]=Offset1[1]>>7;
Offset[2]=Offset1[2]>>7;
#ifndef NON_INT
}
#endif
return;
}
void main(int argc,char **argv)
{
int i,w;
if(argc!=1){
for(i=0;argv[1][i]!='\0';i++){
Space[0].obj_no*=10;
if(argv[1][i]<'0' || argv[1][i]>'9'){
printf("パラメータエラーです.\n");
return;
}
Space[0].obj_no+=(int)(argv[1][i]-'0');
}
}
Step=2;
if(Step==0){
printf("パラメータエラーです.\n");
return;
}
printf("Step=%d\n",Step);
printf("画面初期化.\n");
EGB_init(Gwork,1536);
EGB_resolution(Gwork,0,5);
// EGB_resolution(Gwork,1,6);
EGB_writePage(Gwork,0);
EGB_clearScreen(Gwork);
EGB_displayStart(Gwork,0,64,0);
EGB_displayStart(Gwork,1,0,0);
EGB_displayStart(Gwork,2,2,2);
EGB_displayStart(Gwork,3,256,256);
EGB_writePage(Gwork,1);
EGB_clearScreen(Gwork);
// EGB_displayStart(Gwork,0,64,0);
// EGB_displayStart(Gwork,1,0,0);
// EGB_displayStart(Gwork,2,2,2);
// EGB_displayStart(Gwork,3,256,256);
EGB_displayPage(Gwork,1,3);
EGB_writePage(Gwork,0);
// SPR_init();
#ifndef NON_INT
i=VSYNC_set(VSYNC_handler);
if(i!=0){
printf("割り込みの登録に失敗しました.\n");
return;
}
#endif
for(;;){
#ifdef NON_INT
#ifndef VSYNC_OFF
wait_VSYNC();
#endif
VSYNC_handler();
#endif
if(End_code==1)break;
if(Draw_end!=2)continue;
Draw_end=0;
clear_screen(W_page,6);
#ifndef STAR_OFF
star(Angle,W_page);
#endif
wirespace(Angle,Offset,OBJ_NUM,W_page);
Draw_end=1;
}
#ifndef NON_INT
VSYNC_end();
#endif
printf("正常終了.\n");
// EGB_init(Gwork,1536);
}